package com.tjnu.losca.config;

import com.tjnu.losca.pojo.Teacher;
import com.tjnu.losca.service.MailService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Losca
 * @date 2021/9/15 15:00
 */
@Component
@Aspect
public class AopConfig {

    @Autowired
    private MailService mailService;
    /**
     * execution(*表示返回类型 后面为方法名 ..表示匹配所有参数)
     */
    @AfterReturning(value = "execution(* com.tjnu.losca.controller.TeacherController.save(..))")
    public void before(JoinPoint point){
        Teacher form = (Teacher) point.getArgs()[0];
        System.out.println(form.getEmail().trim());
        mailService.asyncService(form.getEmail().trim());
    }



}
